package binary_tree.Heap.leetcode;

/**
 * @Description: 猜数字的大小
 * @Author Stark
 * @Date 2022/3/8 20:50
 **/

public class Num374_GuessNumber {
    public int guessNumber(int n) {
        int left = 1;
        int right = n;
        while(left <= right){
            //防止溢出
            int mid = (right - left) / 2 + left;
            int choice = guess(mid);
            if(choice == -1){
                right = mid - 1;
            }else if(choice == 1){
                left = mid + 1;
            }else{
                return mid;
            }
        }
        return -1;
    }

    //用于判断你输入的和机器选择的数的大小
    private int guess(int mid) {
        return 0;
    }
}
